<?php
namespace app\web\api;
use app\src\user\enum\RegFromEnum;
use app\src\user\enum\RoleEnum;
use app\web\helper\WebApiHelper;

/**
 * Created by PhpStorm.
 * User: Gooraye
 * Date: 2017-06-03
 * Time: 13:53
 */
class SellerApi
{

    /**
     * 商家接口
     */
    public static function queryNearby($city_code, $lng, $lat, $name,$maxDistance,$page_index,$page_size, $cate = '')
    {
        $data = [
            'api_ver' => '100',
            'city_code' => $city_code,
            'lng' => $lng,
            'lat' => $lat,
            'name' => $name,
            'maxDistance' => $maxDistance,
            'page_index' => $page_index,
            'page_size' => $page_size,
            'cate_id' => $cate

        ];
        return WebApiHelper::callRemote('By_Seller_queryNearby', $data);
    }

    /**
     * 商家接口
     */
    public static function queryAllCategory()
    {
        $data = [
            'api_ver' => '100'


        ];
        return WebApiHelper::callRemote('By_Seller_queryAllCategory', $data);
    }

    public static function childAll($platform_id)
    {
        $data = [
            'api_ver' => '100',
            'platform_id' => $platform_id


        ];
        return WebApiHelper::callRemote('By_Seller_childAll', $data);
    }
    public static function addByPersonalPlatform($platform_id,$name,$price,$scope,$discount_rate,$rack_back_rate,$contact_number,$account_mobile,$first_offer,$account_psw,$logo,$main_img,$main_img_small,$position,$bank_card_name,$bank_card_no,$first_offer_num,$category_id)
    {
        $data = [
            'api_ver' => '100',
            'platform_id' => $platform_id,
            'name' => $name,
            'price' => $price,
            'scope' => $scope,
            'discount_rate' => $discount_rate,
            'rack_back_rate' => $rack_back_rate,
            'contact_number' => $contact_number,
            'account_mobile' => $account_mobile,
            'account_psw' => $account_psw,
            'first_offer' => $first_offer,
            'first_offer_num' => $first_offer_num,
            'position' =>$position,
            'logo' => $logo,
            'main_img' => $main_img,
            'main_img_small' => $main_img_small,
            'bank_card_name' => $bank_card_name,
            'bank_card_no' => $bank_card_no,
            'category_id' => $category_id

        ];
        return WebApiHelper::callRemote('By_Seller_addByPersonalPlatform', $data);
    }

    public static function detail($seller_id)
    {
        $data = [
            'api_ver' => '100',
            'seller_id' => $seller_id
        ];
        return WebApiHelper::callRemote('By_Seller_detail', $data);
    }

    public static function addPromotion($s_id,$seller_id,$uid,$title,$detail,$img)
    {
        $data = [
            'api_ver' => '100',
            's_id' => $s_id,
            'seller_id' => $seller_id,
            'uid' => $uid,
            'title'=>$title,
            'detail'=>$detail,
            'img'=>$img
        ];
        return WebApiHelper::callRemote('By_Seller_addPromotion', $data);
    }

    public static function delPromotion($seller_id,$uid,$promotion_id)
    {
        $data = [
            'api_ver' => '100',
            'promotion_id' => $promotion_id,
            'seller_id' => $seller_id,
            'uid' => $uid
        ];
        return WebApiHelper::callRemote('By_Seller_delPromotion', $data);
    }


    public static function countInfo($account_id,$account_type)
    {
        $data = [
            'api_ver' => '100',
            'account_id' => $account_id,
            'account_type' => $account_type
        ];
        return WebApiHelper::callRemote('By_Seller_countInfo', $data);
    }

    public static function queryConsume($uid,$page_index,$page_size = 10)
    {
        $data = [
            'api_ver' => '100',
            'uid' => $uid,
            'page_index' => $page_index,
            'page_size' => $page_size
        ];
        return WebApiHelper::callRemote('By_Seller_queryConsume', $data);
    }

    public static function getFriend($uid,$types,$page){
        $data = [
            'api_ver' => '100',
            'uid' => $uid,
            'p' => $page,
            'types' => $types
        ];

        return WebApiHelper::callRemote('By_Seller_getrelationship', $data);
    }
}